{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "a626806f",
   "metadata": {},
   "source": [
    "# Multimeter\n",
    "\n",
    "With the PSLab's multimeter, we can measure voltage, resistance, and capacitance.\n",
    "\n",
    "## Required Equipment\n",
    "\n",
    "- Jumper wire\n",
    "- Resistor\n",
    "- Capacitor\n",
    "\n",
    "Start by importing the library and connecting to the device:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "d28716be",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pslab\n",
    "psl = pslab.ScienceLab()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b8fb153b",
   "metadata": {},
   "source": [
    "The ScienceLab class provides a common interface to the PSLab's instruments, the oscilloscope being one example. Let's take a look at how we can use it to collect some data:\n",
    "\n",
    "## Measuring Voltage"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "491c3d1d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.17084249084249084"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "psl.multimeter.measure_voltage()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "daf62f08",
   "metadata": {},
   "source": [
    "That's the voltage at the VOL pin (in volts, V), relative to the PSLab's ground. It's close to zero, since the pin is not connected to anything. It's not *exactly* zero, due to a number of factors such as electromagnetic noise in the environment, electromagnetic noise from the PSLab itself, and from imperfections in the ADC.\n",
    "\n",
    "We can also measure the voltage at pins other than VOL:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "ae14ba8b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.0018887362637362015"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "psl.multimeter.measure_voltage(channel=\"CH1\")"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "857637a5",
   "metadata": {},
   "source": [
    "By connecting the measured pin to one of the VDD pins, we can see what the voltage level is at VDD:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "4a1a6ae5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3.3"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "psl.multimeter.measure_voltage()"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "610d86e9",
   "metadata": {},
   "source": [
    "## Measuring Resistance\n",
    "\n",
    "By connecting a resistor between the RES pin and a GND pin, we can measure its resistance (Ohm, Ω).\n",
    "\n",
    "![resistance](images/resistor.jpg)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "98666b09",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "324.54545454545456"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "psl.multimeter.measure_resistance()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a2f64321",
   "metadata": {},
   "source": [
    "That's it for the multimeter! Now that we know how to use the multimeter, we will use it to get familiar with the PSLab's power supply instrument."
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
